<%-- 
    Document   : index
    Created on : 2009-3-23, 18:02:37
    Author     : LIUGeorge
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java" import="java.sql.*, java.io.*, java.util.*, database.*" %>
<jsp:useBean id="con" class="database.DatabaseConnection"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Homepage</title>
    </head>
    <%
        String logedInAdmin = (String) session.getAttribute("logedInAdmin");
        System.out.println("aaa" + logedInAdmin);
        if (logedInAdmin == null) {

            String username = request.getParameter("username");
            String password = request.getParameter("password");
            String type = request.getParameter("type");
            //System.out.println(username + password);

            con.createConnection();
            if (username != null || password != null) {

                if (con.checkAdministatorName(username, type)) {
                    if (con.checkAdminister(username, password, type)) {
                        if (type.equals("admin")) {
                            session.setAttribute("logedInAdmin", username);
                        } else {
                            session.setAttribute("logedInManu", username);
                        }
    %>
    <frameset rows="80,*" cols="*" frameborder="no" border="0" framespacing="0">
        <frame src="top_frame.jsp" name="topFrame" scrolling="No" noresize="noresize" id="topFrame" title="topFrame" />
        <frameset rows="*" cols="200,*" framespacing="3" frameborder="no" border="3" bordercolor="#666666">
            <frame src="left_frame.jsp" name="leftFrame" scrolling="No" noresize="noresize" id="leftFrame" title="leftFrame" />
            <frame src="main_frame.jsp" name="mainFrame" id="mainFrame" title="mainFrame" />
        </frameset>
    </frameset>
    <%
                } else {
                    out.println("<center>The password is incorrect<br>");
                    out.println("<input align=\"center\" type=\"button\" value=\"back\" onclick=\"window.history.back()\"></center>");
                }

            } else {
                out.println("<center>User is not existing!<br>");
                out.println("<input align=\"center\" type=\"button\" value=\"back\" onclick=\"window.history.back()\"></center>");
            }

        } else {

    %>
    <center>
    Please login first! <br>
        <a href = "login.jsp" target="_self"> login </a>
    </center>
    <%            }
        }
    %>
    <noframes><body>
        </body>
    </noframes>
</html>
